package cn.kinggm520.listener;

/**
 * 作者: kinggm Email:731586355@qq.com
 * 时间:  2020-05-12 21:00
 */

import cn.kinggm520.config.RabbitMQConfig;
import cn.kinggm520.service.GoodsESService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GoodsListener {

    @Autowired
    private GoodsESService goodsESService;

    @RabbitListener(queues = RabbitMQConfig.QUEUE1)
    public void goodsListener1(String jsonGoods){

        System.out.println("接收到消息========================="+jsonGoods);

//        添加文档
        try {
           goodsESService.saveGoods(jsonGoods);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}